import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaLocaleProvider } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;

@inject('portalThemeStore')
@observer
class E9Home extends React.Component {
  constructor(props) {
    super(props);
    this.onHomeClick = this.onHomeClick.bind(this);
  }

  render() {
    const { portalThemeStore } = this.props;
    const { hiddenMyPortal, themeInfo = {} } = portalThemeStore;
    const { themeData = {} } = themeInfo;
    const { styleConfig = {} } = themeData;
    const { topmenu = {} } = styleConfig;

    if (hiddenMyPortal || topmenu.style == 'text') {
      return <div />;
    }

    return (
      <div className="e9header-home" title={getLabel(513043, '我的门户')} onClick={this.onHomeClick}>
        <div className="e9header-home-icon">
          <i className="wevicon-home" />
        </div>
      </div>
    );
  }

  onHomeClick() {
    const { portalThemeStore } = this.props;
    portalThemeStore.getHome();
  }
}

export default E9Home;
